#pragma once

#include "cocos2d.h"
#include "game_map.h"
#include "scene_camera.h"

#define DISPLAY_MARGIN 600;

class BaseEntity;

class BaseScene : public cocos2d::Ref
{
public:
    BaseScene()
        :_sceneId(0)
        ,_camera(nullptr)
        ,_map(nullptr)
        ,_stage(nullptr)
        ,_farLayer(nullptr)
        ,_topEffectLayer(nullptr)
        ,_goLayer(nullptr)
        ,_bottomEffectLayer(nullptr)
    {
    }
    virtual ~BaseScene();
    virtual bool init();
    virtual void setup(int sceneId_);
    virtual void render(long tick);

    virtual void addEntity(BaseEntity *entity);
    virtual void removeEntity(BaseEntity *entity);
    virtual void removeEntity(int id);
    virtual void removeAllEntity();
    
    cocos2d::Layer* getStage() { return _stage; }
    SceneCamera* getCamera() { return _camera; }
    GameMap* getMap() { return _map; }
    BaseEntity* getEntity(int id);
    int getSceneId() { return _sceneId; }

protected:
    int _sceneId;

    cocos2d::Vector<BaseEntity*> _entities;
    SceneCamera *_camera;
	GameMap *_map;

    cocos2d::Layer* _stage;
    cocos2d::Layer* _farLayer;
    cocos2d::Layer* _topEffectLayer;
    cocos2d::Layer* _goLayer;
    cocos2d::Layer* _bottomEffectLayer;
    cocos2d::Layer* _nearLayer;
};

bool depthCompare(BaseEntity *entity1, BaseEntity *entity2);